<template>
    <van-tabs v-model:active="active" animated>
        <van-tab title="首页">
            <div class="ms" v-show="status">
                <h1>秒杀倒计时</h1>
                <span>{{ msdata }}</span>
            </div>
            <!-- 搜索区域 -->
            <Search></Search>
        </van-tab>
        <van-tab title="影视">内容 2</van-tab>
        <van-tab title="美食" class="food">
            <!-- 骨架屏 -->
             <van-skeleton title :row="10" v-if="gj"/>
            <div class="fooditems" v-else>
                <div></div>
                <div></div>
                <div></div>
                <div></div>
                <div></div>
                <div></div>
                <div></div>
                <div></div>
                <div></div>
                <div></div>
            </div>

        </van-tab>
        <van-tab title="音乐">内容 4</van-tab>
        <van-tab title="电影">内容 4</van-tab>
    </van-tabs>

</template>

<script setup>
import { ref } from 'vue'
// 引入搜索组件
import Search from '@/components/search.vue'
// 默认切换内容
let active = ref(0)
// 自定义秒杀数据
let msdata = ref(5)
let status = ref(true)
let timer = setInterval(() => {
    msdata.value--
    if (msdata.value == 0) {
        clearInterval(timer)
        msdata.value = 5;
        status.value = false
    }
}, 1000);
// 骨架屏区域
let gj = ref(true)
setTimeout(()=>{
    gj.value = false
},2000)
</script>

<style lang="scss" scoped>
.ms {
    width: 100%;
    height: 200px;
    background: skyblue;
}

.food {
    .fooditems div {
        width: 100px;
        height: 150px;
        background: skyblue;
        display: flex;
        flex-wrap: wrap;
        float: left;
        margin-left: 50px;
        margin-top: 20px;
        column-count: 2;
    }
}
</style>